<!--  -->
<template>
  <a-row class="requiredFormItem">
    <a-col :span="16">
      <a-form-model-item label="所属单位">
      <org-tree-select :value="form.projectId" disabled></org-tree-select>
      </a-form-model-item>
    </a-col>
    <a-col v-for="(item, index) in items" :key="index" :span="item.span ? item.span : 8">
      <a-form-model-item :label="item.label" :prop="item.value">
        <template v-if="item.scopedSlots && item.scopedSlots.customRender">
          <a-input disabled :value="isKeyProjectHandler(form[item.value])" v-if="item.scopedSlots.customRender === 'isKeyProject'" />
          <BaseTextarea v-model="form[item.value]"  v-if="item.scopedSlots.customRender === 'BaseTextarea'" :disabled="item.disabled" :maxLength='3000'></BaseTextarea>
        </template>
        <component v-else :is="item.type" v-model="form[item.value]" :disabled="item.disabled"></component>
      </a-form-model-item>
    </a-col>
  </a-row>
</template>

<script>
export default {
  name: 'BaseInfo',
  props: {
    form: {
      type: Object,
      default: () => {}
    },
    pageType: String
  },
  data() {
    return {
      items: [
        // {
        //   type: 'a-input',
        //   label: '分公司',
        //   disabled: true,
        //   value: 'branchName'
        // },
        // {
        //   type: 'a-input',
        //   label: '项目名称',
        //   disabled: true,
        //   value: 'projectName'
        // },
        {
          type: 'a-input',
          label: '项目编号',
          disabled: true,
          value: 'projectCode'
        },
        {
          type: 'a-input',
          label: '是否重点项目',
          disabled: true,
          value: 'isKeyProject',
          scopedSlots: { customRender: 'isKeyProject' }
        },
        {
          type: 'a-input',
          label: '编制人',
          disabled: true,
          value: 'modifiedName'
        },
        {
          type: 'a-input',
          label: '编制时间',
          disabled: true,
          value: 'modifiedTime'
        },
        {
          type: 'BaseTextarea',
          label: '项目基本情况',
          span: 24,
          value: 'basicInfo',
           scopedSlots: { customRender: 'BaseTextarea' }
        }
      ]
    }
  },

  components: {},

  computed: {},

  created() {},

  watch: {
    pageType: {
      handler(val) {
        if (val === 'look') {
          this.items.map((v) => {
            if (v.value === 'basicInfo') {
              v.disabled = true
            }
          })
        }
      },
      immediate: true
    }
  },

  mounted() {},

  methods: {
    isKeyProjectHandler(val) {
      if (Number(val) === 1) {
        return '是'
      }
      return '否'
    }
  }
}
</script>
<style lang='less' scoped>
</style>
